<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function ajax(url){
            return new Promise((resolve,reject)=>{
                let xhr =new XMLHttpRequest()
                xhr.open('get',url) //get请求，请求路径
                xhr.send()//获取资源
                xhr.onreadystatechange=function(){//当状态发生改变时
                    console.log(xhr);
                    if(xhr.readyState==4){//readyState 状态一直发生改变，值为四时，请求动作完成
                        if(xhr.status >=200 && xhr.status < 300){
                           let res=JSON.parse( xhr.responseText)
                              resolve()
                        } else{reject(xhr.responseText)}          
                     }
                }
            })
        }
        
        
        ajax('./01.json').then((res)=>{
            console.log(res);
            return ajax('./02.json')
        })
        .then(()=>{
            console.log(res);
            return ajax('./03.json')

        })
        .then(()=>{
            console.log(res);
    

        })
        .catch((error=>{
            console.log(error)
        }))
        
        
     
            </script>
        
</body>
</html>